// simplest.cpp in folder tests
#include <UnitTest++.h>
#include "..\MyMap.h"
#include <string>
#include <map>

TEST(MyMapAlwaysPass)
{
	CHECK(true);
}
TEST(MyMapDefaultConstructor)
{
	MyMap<long> mmLong;
}

TEST(MyMapCreationFromPair)
{
	MyMap<long> mmLong("hello",1);
	CHECK_EQUAL(1L, mmLong["hello"]);
	MyMap<std::string> mmString("hello","greetings");
	CHECK_EQUAL("greetings", mmString["hello"]);
}

TEST(MyMapCreationFromSingleString)
{
	std::string s = "one 1;two 22;three 333.3;four 44ddd;";
	MyMap<long> mmLong(s);
	CHECK_EQUAL(1, mmLong["one"]);
	CHECK_EQUAL(22, mmLong["two"]);
	CHECK_EQUAL(333, mmLong["three"]);
	CHECK_EQUAL(44, mmLong["four"]);

	MyMap<double> mmDouble(s);
	CHECK_CLOSE(1.0, mmDouble["one"],1e-10);
	CHECK_CLOSE(22.0, mmDouble["two"],1e-10);
	CHECK_CLOSE(333.3, mmDouble["three"],1e-10);
	CHECK_CLOSE(44.0, mmDouble["four"],1e-10);

	MyMap<std::string> mmString(s);
	CHECK_EQUAL("1", mmString["one"]);
	CHECK_EQUAL("22", mmString["two"]);
	CHECK_EQUAL("333.3", mmString["three"]);
	CHECK_EQUAL("44ddd", mmString["four"]);

}

TEST(MyMapInitializingAStandardMap)
{
	std::string s = "one 1;two 22;three 333.3;four 44ddd;";
	std::map<std::string, long> m = MyMap<long>(s);
	CHECK_EQUAL(1, m["one"]);
	CHECK_EQUAL(22, m["two"]);
	CHECK_EQUAL(333, m["three"]);
	CHECK_EQUAL(44, m["four"]);
}

